var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("GlobalUserData"),
s = t("BoxGetView"),
l = t("Util"),
c = t("StorageManager"),
d = t("BaseStorage"),
h = t("ChampionManager"),
p = cc._decorator,
u = p.ccclass,
f = p.property,
m = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.node_cur = null,
        e.node_next = null,
        e.label_curGrade = null,
        e.label_nextGrade = null,
        e.pfb_box = null,
        e.spr_box = null,
        e.frame_box = [],
        e.btn_getBox = null,
        e.label_title = null,
        e.frame_got = null,
        e.spr_btnTxt = null,
        e.gradeLevelBoxgetKey = "gradeLevelBoxgetKey",
        e
    }
    return n(e, t),
    e.prototype.onEnable = function() {
        l.Util.showLeftSingleCustomAd(),
        this.curLevel = h.default.Ins.getGradeLevel(r.default.nTrophy),
        c.StorageManager.setDailyTaskStorageKey(this.gradeLevelBoxgetKey),
        this.refreshGetBtnSstatus(),
        this.label_title.string = h.default.Ins.getGradeName(this.curLevel) + "段位每日奖励",
        this.label_curGrade.string = h.default.Ins.getGradeName(this.curLevel);
        for (var t = this.getBuffTip(h.default.Ins.getGradeBuff(r.default.nTrophy, null)), e = 1, o = 0; o < this.node_cur.children.length; o++) {
            var i = this.node_cur.children[o];
            "" == t[o] ? i.active = !1 : (i.getComponent(cc.Label).string = e + "、" + t[o], e++)
        }
        if (this.curLevel < h.GradeLevel.superGrade) {
            this.label_nextGrade.string = h.default.Ins.getGradeName(this.curLevel + 1),
            t = this.getBuffTip(h.default.Ins.getGradeBuff(null, this.curLevel + 1));
            var n = 1;
            for (o = 0; o < this.node_next.children.length; o++) i = this.node_next.children[o],
            "" == t[o] ? i.active = !1 : (i.getComponent(cc.Label).string = n + "、" + t[o], n++)
        } else this.label_nextGrade.node.active = !1,
        this.node_next.active = !1;
        this.spr_box.spriteFrame = this.frame_box[this.getBoxType()]
    },
    e.prototype.onDisable = function() {
        l.Util.hideLeftSingleCustomAd(),
        l.Util.showRightSingleCustomAd()
    },
    e.prototype.refreshGetBtnSstatus = function() {
        d.BaseStorage.getInt(this.gradeLevelBoxgetKey, 0) ? (this.btn_getBox.interactable = !1, this.spr_btnTxt.spriteFrame = this.frame_got) : this.btn_getBox.interactable = !0
    },
    e.prototype.getBuffTip = function(t) {
        var e = [];
        return 0 == t.goldBuff ? e.push("") : e.push("结算金币增加:" + Math.floor(100 * t.goldBuff) + "%"),
        0 == t.vitBuff ? e.push("") : e.push("体力上限增加:" + t.vitBuff.toString()),
        0 == t.upgrade ? e.push("") : e.push("升级战车消耗降低:" + Math.floor(100 * t.upgrade) + "%"),
        0 == t.lottery ? e.push("") : e.push("幸运抽奖免费机会增加:" + t.lottery.toString()),
        e.push("每日领取宝箱品质:" + t.box),
        e
    },
    e.prototype.getBoxGift = function() {
        var t = this.getBoxType() + 1,
        e = cc.instantiate(this.pfb_box);
        cc.find("Canvas").addChild(e),
        e.getComponent(s.default).showOpenBoxView(t, null),
        d.BaseStorage.setInt(this.gradeLevelBoxgetKey, 1),
        this.refreshGetBtnSstatus()
    },
    e.prototype.getBoxType = function() {
        return this.curLevel >= h.GradeLevel.bronzeGrade && this.curLevel <= h.GradeLevel.goldGrade ? 0 : this.curLevel >= h.GradeLevel.platinumGrade && this.curLevel <= h.GradeLevel.diamondGrade ? 1 : this.curLevel >= h.GradeLevel.kingGrade && this.curLevel <= h.GradeLevel.superGrade ? 2 : void 0
    },
    e.prototype.onBtnClose = function() {
        this.node.destroy()
    },
    a([f(cc.Node)], e.prototype, "node_cur", void 0),
    a([f(cc.Node)], e.prototype, "node_next", void 0),
    a([f(cc.Label)], e.prototype, "label_curGrade", void 0),
    a([f(cc.Label)], e.prototype, "label_nextGrade", void 0),
    a([f(cc.Prefab)], e.prototype, "pfb_box", void 0),
    a([f(cc.Sprite)], e.prototype, "spr_box", void 0),
    a([f([cc.SpriteFrame])], e.prototype, "frame_box", void 0),
    a([f(cc.Button)], e.prototype, "btn_getBox", void 0),
    a([f(cc.Label)], e.prototype, "label_title", void 0),
    a([f(cc.SpriteFrame)], e.prototype, "frame_got", void 0),
    a([f(cc.Sprite)], e.prototype, "spr_btnTxt", void 0),
    a([u], e)
} (cc.Component);
o.default = m